/**
 * 时间组件
 */

(function ($) {

    //实现类
    var Clock = function ($ele, ops) {
        $ele.clockpicker(ops);
    };

    //插件定义
    jx.plugin({
        name: 'jxclock',
        instance: function ($ele, ops) {
            return Clock($ele, ops);
        },
        defaults: {
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            todayBtn: 'linked',
            autoclose: true,
            todayHighlight: true,
            templates: {
                leftArrow: '<span class="fa fa-arrow-left"></span>',
                rightArrow: '<span class="fa fa-arrow-right"></span>'
            }
        }
    });

    //注册依赖
    jx.onBeforeInit(function (e) {
        if (document.querySelector('.jxclock')) {
            jx.depend('clockpicker');
        }
    });

    //实例化
    jx.onInit(function (e) {
        $(e.target).find('.jxclock').jxclock();
    });

}(jQuery));